package com.xspace.android.xafcommon.http.resp;

import com.google.gson.Gson;
import com.xspace.android.xafcommon.network.exception.DecodeMessageException;
import com.xspace.android.xafcommon.network.message.AResponseMsg;
import com.xspace.android.xafcommon.util.LogUtils;


public abstract class ResponseMsg extends AResponseMsg {
	protected Gson mGson;
    public boolean htmlFlag=false;
    public boolean isImg=false;
    public byte[] imgDate;
	@Override
	public void parseData(byte[] data) throws DecodeMessageException {
		if(data==null){
			retCode=-1;
			return;
		}
		if(isImg){
			this.imgDate=data;
			return;
		}
		String result = "";
		mGson = new Gson();
		try {
			System.out.println("wubaojie-----data:"+data);
			result = new String(data, "UTF-8").toString();
			System.out.println("wubaojie--------result:"+result);
			if (htmlFlag) {
				parseJson(result);
				return;
			}
			LogUtils.d("wubaojie Response msg==>" + result);
			parseJson(result);
		} catch (Exception e) {
			throw new DecodeMessageException(e.getMessage());
		}
	}

	protected abstract void parseJson(String jsonData) throws Exception;

}
